﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class admin_bat_dong_san_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            bindHome();
        }
        catch (Exception ex) { }
    }
    protected void bindHome()
    {
        Home_Info[] lstHome = Home_Info.searchHome("",0, "");

        repDanhMucNha.DataSource = lstHome.Take(16);
        repDanhMucNha.DataBind();

        int totalPage = (int)Math.Ceiling(ConvertUtility.ToDouble(lstHome.Length) / 16);
        pagerbot.Text = ConvertUtility.buildSimplePaging(totalPage, 1);
    }
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {

            string[] arrKeyDel = hidKeyDel.Value.Split('|');

            for (int i = 0; i < arrKeyDel.Length - 1; i++)
            {
                Home_Info homeInfo = Home_Info.Find(Convert.ToInt32(arrKeyDel[i].Trim()));
                Image_Info.DeleteAll("imageObjectID=" + homeInfo.id + " and imageType=1");
                Home_Cat_Info.DeleteAll("homeID=" + homeInfo.id);
                homeInfo.DeleteAndFlush();
            }
            Response.Redirect("/admin/bat-dong-san/default.aspx");

        }
        catch (Exception ex)
        {
            lblMessage.Text = "Có lỗi xảy ra. Hãy thử lại";
            fail.Visible = true;
        }
    }
   
}